package com.jic.product.impl;

import java.lang.Long;
import java.util.List;

import com.jic.product.entity.CategoryPropertyValue;
import com.jic.product.mapper.CategoryPropertyValueMapper;
import com.jic.product.service.CategoryPropertyValueService;
import com.jic.common.base.vo.Page;
import com.jic.common.base.vo.PageResult;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 类目属性值表
 * @author : 
 * @email : 
 * @since : 2020-01-10 07:03:01
 * @version : v1.0.0
 */
@Service
public class CategoryPropertyValueServiceImpl implements CategoryPropertyValueService{

    @Autowired
    private CategoryPropertyValueMapper categoryPropertyValueMapper;

    @Override
    public long insert(CategoryPropertyValue categoryPropertyValue) {
        long flag = categoryPropertyValueMapper.insert(categoryPropertyValue);
        return flag;
    }

    @Override
    public long delete(Long id) {
        return categoryPropertyValueMapper.delete(id);
    }

    @Override
    public long update(CategoryPropertyValue categoryPropertyValue) {
        return categoryPropertyValueMapper.update(categoryPropertyValue);
    }

    @Override
    public CategoryPropertyValue queryByPrimaryKey(Long id){
        return categoryPropertyValueMapper.queryByPrimaryKey(id);
    }

    @Override
    public List<CategoryPropertyValue> query(CategoryPropertyValue categoryPropertyValue){
        return categoryPropertyValueMapper.query(categoryPropertyValue);
    }

    @Override
    public PageResult<CategoryPropertyValue> queryPage(CategoryPropertyValue categoryPropertyValue, Page pageQuery) {
        //计算下标
        int startIndex = (pageQuery.getStart() - 1) * pageQuery.getLimit();
        List<CategoryPropertyValue> list = categoryPropertyValueMapper.queryPage(startIndex, pageQuery.getLimit(), categoryPropertyValue);
        long count = categoryPropertyValueMapper.queryPageCount(categoryPropertyValue);
        PageResult pageResult = new PageResult();
        pageResult.setRows(list);
        pageResult.setTotal(count);
        return pageResult;
    }
}